<div ms-controller="announcement" class="col-md-9">
    <h1>公告管理</h1>
    <table class="table table-striped">
        <tr>
            <th>编号</th>
            <th>标题</th>
            <th>创建时间</th>
            <th>更新时间</th>
            <th>创建者</th>
            <th>可见</th>
            <th></th>
        </tr>
        <tr ms-repeat="announcementList">
            <td>{{ el.id }}</td>
            <td>{{ el.title }}</td>
            <td>{{ el.create_time|date("yyyy-MM-dd HH:mm:ss")}}</td>
            <td>{{ el.last_update_time|date("yyyy-MM-dd HH:mm:ss")}}</td>
            <td>{{ el.created_by.username }}</td>
            <td ms-text="el.visible?'可见':'不可见'"></td>
            <td>
                <button class="btn-sm btn-info" ms-click="editAnnouncement(el)">编辑</button>
            </td>
        </tr>
    </table>
    <div class="form-group">
        <label>仅显示可见 <input ms-duplex-checked="showVisibleOnly" type="checkbox"/></label>
    </div>
    <div class="right">
        <ms:pager $id="announcementPager" config="pager"></ms:pager>
    </div>

    <div ms-visible="isEditing">
        <h3>编辑公告</h3>

        <div class="form-group">
            <label>标题</label>
            <input name="title" type="text" class="form-control" id="newTitle" placeholder="公告标题" value=""
                   ms-duplex="newTitle"></div>
        <div class="form-group">
            <label>内容</label>
            <ms:editor $id="editAnnouncementEditor" config="editAnnouncementEditor"></ms:editor>
        </div>
        <div class="form-group">
            <label>可见 <input ms-duplex-checked="announcementVisible" type="checkbox"/></label>
        </div>

        <div class="form-group">
            <button ms-click="submitChange()" class="btn btn-success">保存修改</button>
            &nbsp;&nbsp;
            <button ms-click="cancelEdit()" class="btn btn-danger">取消</button>
        </div>
    </div>
    <h3>发布公告</h3>

    <form id="announcement-form">
        <div class="form-group">
            <label>标题</label>
            <input name="title" type="text" class="form-control" id="title" placeholder="公告标题"
                   data-error="请填写公告标题(标题不得超过50字)" maxlength="50" required>

            <div class="help-block with-errors"></div>
        </div>
        <div class="form-group">
            <label>内容</label>

            <ms:editor $id="createAnnouncementEditor" config="createAnnouncementEditor"></ms:editor>

            <div class="help-block with-errors"></div>
        </div>

        <div class="form-group">
            <button type="submit" class="btn btn-success">发布公告</button>
        </div>
    </form>
</div>
<script src="/static/js/app/admin/announcement/announcement.js"></script>